import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/home.vue'
import Cart from '@/views/cart.vue'
import Cate from '@/views/cate.vue'
import Self from '@/views/self.vue'
import NotFound from '@/views/notFound.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      name: 'home',
      component: Home
    },
    {
      path: '/cate',
      name: 'cate',
      component: Cate
    },
    {
      path: '/cart',
      name: 'cart',
      component: Cart,
    },
    {
      path: '/self',
      name: 'self',
      component: Self
    },
    {
      path: '/search',
      name: 'search',
      component: () => import('@/components/search/index.vue'),
      meta: { hidFooter: true }
    },
  
    {
      path: '/login',
      name: 'login',
      component: () => import('@/components/login/index.vue'),
    },
    {
      path: '/detail',
      name: 'detail',
      component: () => import('@/components/details.vue'),
      meta: { hidFooter: true }
    },
    {
      path: '/list',
      name: 'list',
      component: () => import('@/components/goodsList.vue'),
      meta: { hidFooter: true }
    },
 
 
    {
      path: '/register',
      name: 'register',
      component: () => import('@/components/register/index.vue'),
    },
    {
      path: '/order',
      name: 'order',
      component: () => import('@/components/order/index.vue'),
    },
    {
      // 找不到路由
      path: '/not-found',
      name: 'not-found',
      component: NotFound,
      meta: { hidFooter: true }
    },
    {
      // 匹配任意内容
      path: '/:pathMatch(.*)*',
      redirect: '/not-found'
    }
  ]
})

export default router